<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<link type="text/css" href="/css/1pxtable.css" rel="Stylesheet" />	
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script>
	function tickAll(source){
		var id = $(source).attr('id');

		var sep = id.split("_");
	
		if(source.checked){
			$('.stf_check_'+sep[1]).prop('checked',true);
		}else{
			$('.stf_check_'+sep[1]).prop('checked',false);
		}
	}

	function toggle(str) {
		var ele = document.getElementById(str);

		if(ele.style.display == "") {
			ele.style.display = "none";
	  	}
		else {
			ele.style.display = "";
		}
	}
</script>
    
    
</head>

<body style="font-family:Arial, Helvetica, sans-serif;">


<form action = "" method="post">
<?php if($this->check == 'simon' || $this->check == 'olga' || $this->check == 'ken'){?>
<h1>Online Leave Application Confirm Page
</h1>
<?php
	  $y = 1;
	  $z = 1;
		$leaveType = unserialize(LEAVE_TYPE);
		$stf = new Model_DbTable_Roster_Staffinfo();
		$stfD = new Model_DbTable_Roster_Stafflogindetail();?>

<h2>Pending Case</h2>
<?php if(!empty($this->pendingCase)){?>
    <?php foreach($this->pendingCase as $k2 => $v2){
    		$i = 1; ?>
    	<input type = "checkbox" id = "checkbox_<?php echo $k2?>" style = "margin-left:1000px;" onclick = "tickAll(this)"></input>Tick All	
    	<table border="1" cellspacing="0" cellpadding="10">
    <tr>
      <th scope="col">No.</th>
      <th scope="col">Type Of Leave</th>
      <th scope="col">Application Date</th>
      <th scope="col">Shop</th>
      <th scope="col">Staff</th>
      
      <th scope="col">Date of Leave</th>
      <th scope="col">Time Period</th>
      <th scope="col">Hours</th>
	  <th scope="col">Detail</th>
	  <th scope="col">Action</th>
	  <th scope="col">Reason</th>
    </tr>
      <?php foreach ($v2 as $k => $v){
    		$stfNi = $stfD->getDetail($v['id_staff']);
    		$fName = Model_EncryptHelper::getSslPassword($stfNi['n']);
    		?>
  			
 

    		<tr>
    			<td width="20" ><?php echo $i++?><input type ="hidden" name = "caseId[<?php echo $v['id_leave']?>]" id = "case_id_<?php echo $v['id_leave']?>" value = "<?php echo $v['id_leave']?>"></input></td>
    			<td><label for="leave_type[<?php echo $v['id_leave']?>]"></label>
        		<select name="leave_type[<?php echo $v['id_leave']?>]">
         			 <option value="1" <?php if($v['period_type'] == 1){?>selected<?php }?>>Annual Leave</option>
         			 <option value="2" <?php if($v['period_type'] == 2){?>selected<?php }?>>Sick Leave</option>
          			 <option value="5" <?php if($v['period_type'] == 5){?>selected<?php }?>>Event Leave</option>
      			</select></td>
    			
    			<td width="80"><?php echo $v['application_date']?></td>
    			<td width="50" ><?php echo $v['shop_code']?></td>
    			<td width="150" ><?php echo $fName." (".$stfNi['ni'].")";?></td>
    			<td width="80" ><?php echo $v['period_start']?></td>
    			<td width="120" ><?php echo $v['period_start_hr'].":".str_pad($v['period_start_min'], 2, "0", STR_PAD_RIGHT);?> ~ <?php echo $v['period_end_hr'].":".str_pad($v['period_end_min'], 2, "0", STR_PAD_RIGHT)?></td>
    			<td width="30" ><?php echo $v['total_hrs']?></td>
    			<td width="200" ><?php echo $v['leave_comm']?></td>
    			<td width="10" ><input type = "checkbox" name = "checkbox[<?php echo $v['id_leave']?>]" id = "checkbox" class = "stf_check_<?php echo $v['id_staff']?>"></input></td>
    			<td width="80" ><input type = "text" name = "reason[<?php echo $v['id_leave']?>]" id = "reason"></input></td>
    		</tr>
    <?php } ?>
    </table> <br/>
  <br/>
    	<?php }?>
    	
<?php }?>
  
  <br/>
  <?php if($this->check == 'simon' || $this->check == 'olga' || $this->check = 'ken'){?>
  <input type = "submit" name = "accept" id = "accept" value = "Accept"></input>
<input type = "submit" name = "reject" id = "reject" value = "Reject"></input>
<?php }?>
<br/><br/>
<h2><a href = "javascript:toggle('acceptcase');">Accept Case History</a></h2>
  <div id = "acceptcase" style="display:none;">
  <?php if(!empty($this->acceptCase)){?>
  
  <table border="1" cellspacing="0" cellpadding="10">
    <tr>
      <th scope="col">No.</th>
      <th scope="col">Type Of Leave</th>
      <th scope="col">Application Date</th>
      <th scope="col">Shop</th>
      <th scope="col">Staff</th>
      <th scope="col">Date of Leave</th>
      <th scope="col">Time Period</th>
      <th scope="col">Hours</th>
	  <th scope="col">Detail</th>
	  <th scope="col">Accept Date</th>
	  <th scope="col">Approval Staff</th>
	  <th scope="col">Status</th>
	  <th scope="col">Paid Date</th>
    </tr>
    <?php foreach($this->acceptCase as $k => $v){
    		$appStf = $stfD->getDetail($v['approved_id_staff']);
    		$stfNi = $stfD->getDetail($v['id_staff']);
    		$fName = Model_EncryptHelper::getSslPassword($stfNi['n']);?>
    		<tr>
    			<td width="20" ><?php echo $y++?><input type ="hidden" name = "caseId[<?php echo $v['id_leave']?>]" id = "case_id_<?php echo $v['id_leave']?>" value = "<?php echo $v['id_leave']?>"></input></td>
    			<td width="80" ><?php echo $leaveType[$v['period_type']];?></td>
    			<td width="80"><?php echo $v['application_date']?></td>
    			<td width="50" ><?php echo $v['shop_code']?></td>
    			<td width="150" ><?php echo $fName." (".$stfNi['ni'].")";?></td>
    			<td width="80" ><?php echo $v['period_start']?></td>
    			<td width="120" ><?php echo $v['period_start_hr'].":".str_pad($v['period_start_min'], 2, "0", STR_PAD_RIGHT);?> ~ <?php echo $v['period_end_hr'].":".str_pad($v['period_end_min'], 2, "0", STR_PAD_RIGHT);?></td>
    			<td width="30" ><?php echo $v['total_hrs']?></td>
    			<td width="200" ><?php echo $v['leave_comm']?></td>
    			<td width="80" ><?php echo $v['approved_date']?></td>
    			<td width="120" ><?php echo $appStf['ni'];?></td>
    			<td><?php if(!$v['paid_date']){ echo 'NOTPAID';}else{echo 'PAID';}?></td>
    			<td><?php echo $v['paid_date']?></td>
    			<?php if($this->check == 'olga' || $this->check = 'ken'){?>
    			<td><?php if(!$v['paid_date']){?><input type = "submit" name = "cancel[<?php echo $v['id_leave']?>]" value = "Cancel"><?php }else{?>&nbsp;<?php }?></input></td>
    			<?php }?>
    		</tr>
    <?php }?>
	
  </table>
  <?php }?>
  </div>
  <h2><a href = "javascript:toggle('rejectcase');">Reject Case History</a></h2>
  <div id = "rejectcase" style="display:none;">
  <?php if(!empty($this->rejectCase)){?>
   
  <table border="1" cellspacing="0" cellpadding="10">
    <tr>
      <th scope="col">No.</th>
      <th scope="col">Type Of Leave</th>
      <th scope="col">Application Date</th>
      <th scope="col">Shop</th>
      <th scope="col">Staff</th>
      <th scope="col">Date of Leave</th>
      <th scope="col">Time Period</th>
      <th scope="col">Hours</th>
	  <th scope="col">Detail</th>
	  <th scope="col">Reject Date</th>
	  <th scope="col">Reject Reason</th>
	  <th scope="col">Approval Staff</th>
    </tr>
    <?php foreach($this->rejectCase as $k => $v){
    		$appStf = $stfD->getDetail($v['approved_id_staff']);
    		$stfNi = $stfD->getDetail($v['id_staff']);
    		$fName = Model_EncryptHelper::getSslPassword($stfNi['n']);?>
    		<tr>
    			<td width="20" ><?php echo $z++?><input type ="hidden" name = "caseId[<?php echo $v['id_leave']?>]" id = "case_id_<?php echo $v['id_leave']?>" value = "<?php echo $v['id_leave']?>"></input></td>
    			<td width="80" ><?php echo $leaveType[$v['period_type']];?></td>
    			<td width="80"><?php echo $v['application_date']?></td>
    			<td width="50" ><?php echo $v['shop_code']?></td>
    			<td width="150" ><?php echo $fName." (".$stfNi['ni'].")";?></td>
    			<td width="80" ><?php echo $v['period_start']?></td>
    			<td width="120" ><?php echo $v['period_start_hr'].":".str_pad($v['period_start_min'], 2, "0", STR_PAD_RIGHT);?> ~ <?php echo $v['period_end_hr'].":".str_pad($v['period_end_min'], 2, "0", STR_PAD_RIGHT);?></td>
    			<td width="30" ><?php echo $v['total_hrs']?></td>
    			<td width="200" ><?php echo $v['leave_comm']?></td>
    			<td width="80" ><?php echo $v['approved_date']?></td>
    			<td width="150" ><?php echo $v['cancel_reason']?></td>
    			<td width="120" ><?php echo $appStf['ni'];?></td>
    		</tr>
    <?php }?>
	
  </table>
 
  <?php }?>
  </div>
  <?php }else{?>
  	<h2>Leave Application Confirm Page</h2>
  	Input your password <input type = "password" name = "password"></input><br/><br/>
  	<input type = "submit" name = "next" value = "Submit"></input>
  <?php }?>	
</form>
</body>
</html>
